using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace LigerUi.MVC.DataModel.EntityClasses.Models.Mapping
{
    public class CF_EmployeeMap : EntityTypeConfiguration<CF_Employee>
    {
        public CF_EmployeeMap()
        {
            // Primary Key
            this.HasKey(t => t.EmployeeID);

            // Properties
            this.Property(t => t.EmployeeNo)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.EmployeeName)
                .IsRequired()
                .HasMaxLength(100);

            this.Property(t => t.Remark)
                .HasMaxLength(4000);

            this.Property(t => t.Guid)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.OfficePhone)
                .HasMaxLength(20);

            this.Property(t => t.WorkPhone)
                .HasMaxLength(20);

            this.Property(t => t.PersonalPhone)
                .HasMaxLength(20);

            this.Property(t => t.RecordStatus)
                .IsRequired()
                .HasMaxLength(20);

            // Table & Column Mappings
            this.ToTable("CF_Employee");
            this.Property(t => t.EmployeeID).HasColumnName("EmployeeID");
            this.Property(t => t.EmployeeNo).HasColumnName("EmployeeNo");
            this.Property(t => t.CompanyID).HasColumnName("CompanyID");
            this.Property(t => t.DepartmentID).HasColumnName("DepartmentID");
            this.Property(t => t.EmployeeName).HasColumnName("EmployeeName");
            this.Property(t => t.Age).HasColumnName("Age");
            this.Property(t => t.BirthDay).HasColumnName("BirthDay");
            this.Property(t => t.JoinDay).HasColumnName("JoinDay");
            this.Property(t => t.LeaveDay).HasColumnName("LeaveDay");
            this.Property(t => t.Remark).HasColumnName("Remark");
            this.Property(t => t.CreateUserID).HasColumnName("CreateUserID");
            this.Property(t => t.CreateDate).HasColumnName("CreateDate");
            this.Property(t => t.ModifyUserID).HasColumnName("ModifyUserID");
            this.Property(t => t.ModifyDate).HasColumnName("ModifyDate");
            this.Property(t => t.Guid).HasColumnName("Guid");
            this.Property(t => t.OfficePhone).HasColumnName("OfficePhone");
            this.Property(t => t.WorkPhone).HasColumnName("WorkPhone");
            this.Property(t => t.PersonalPhone).HasColumnName("PersonalPhone");
            this.Property(t => t.RecordStatus).HasColumnName("RecordStatus");

            // Relationships
            this.HasOptional(t => t.CF_Company)
                .WithMany(t => t.CF_Employee)
                .HasForeignKey(d => d.CompanyID);
            this.HasRequired(t => t.CF_Department)
                .WithMany(t => t.CF_Employee)
                .HasForeignKey(d => d.DepartmentID);

        }
    }
}
